﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Project.Web.Base;
using CNDreams.Web.Areas.ModuleSys.Models;
using Project.Web.Base.Utility;
using CNDreams.Web.Base;
using CNDreams.Enum;
using Project.Common;

namespace CNDreams.Web.Areas.ModuleSys.Controllers
{
	public class PasswordRetrieveController : BaseController
	{
		public ActionResult Index(ModelPasswordRetrieveIndex model)
		{
			if (SessionManager.CurrentSysUser.UserType != (int)EnumInternalUserType.多方登录账号)
				return Content("无此权限进行查看");
			if (!SessionManager.IsMutipleUserLogined.Value)
			{
				string url = string.Format("/ModuleSys/PasswordRetrieve/Login?RetUrl={0}", HttpUtility.UrlEncode(Request.Url.LocalPath.ToString()));
				string script = string.Format("window.top.openDialog({{Url:'{0}',Width:800,Height:400,Title:'多方认证登录'}})", url);
				return Content(WebTools.GetScript(script));
			}

			model.RetriveData();
			return View(model);
		}


		[HttpPost]
		public ActionResult EmailRetrieve(Guid? userID)
		{
			JsonResult jsresult = new JsonResult();
			jsresult.ContentType = Consts.CONTENT_TYPE;
			jsresult.Data = new { result = string.Empty };
			try
			{
				//发送邮件
				jsresult.Data = new { result = string.Empty };
			}
			catch
			{
				jsresult.Data = new { result = CNDreams.Resources.Properties.Resources.M00002E };
			}
			return jsresult;
		}

		[HttpPost]
		public ActionResult MessageRetrieve(Guid? messageID)
		{
			JsonResult jsresult = new JsonResult();
			jsresult.ContentType = Consts.CONTENT_TYPE;
			jsresult.Data = new { result = string.Empty };
			try
			{
				//发送短信
				jsresult.Data = new { result = string.Empty };
			}
			catch
			{
				jsresult.Data = new { result = CNDreams.Resources.Properties.Resources.M00002E };
			}
			return jsresult;
		}
	}
}
